/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.UsuallyEmployMapper;
import com.ybkj.daijia.server.model.UsuallyEmploy;
import com.ybkj.daijia.server.model.UsuallyEmploy.ServiceType;
import com.ybkj.daijia.server.service.UsuallyEmployService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultUsuallyEmployService implements UsuallyEmployService {

    @Autowired
    private UsuallyEmployMapper usuallyEmployMapper;


    @Transactional(rollbackFor = Exception.class)
    public UsuallyEmploy insertRecord(UsuallyEmploy usuallyEmploy) {

        usuallyEmployMapper.insertRecord(usuallyEmploy);

        return usuallyEmploy;
    }

    @Transactional(rollbackFor = Exception.class)
    public void delete(UsuallyEmploy usuallyEmploy) {

        usuallyEmployMapper.deleteByPrimaryKey(usuallyEmploy.getId());

    }

    @Override
    public UsuallyEmploy findOne(Long id) {

        return usuallyEmployMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<UsuallyEmploy> getUsuallyEmploy(Long passengerId, String serviceType) {

        return usuallyEmployMapper.selectByPassenger(passengerId, serviceType);

    }

    @Override
    public UsuallyEmploy findByEmployAndPassenger(Long employId, Long passengerId,
        ServiceType serviceType) {

        return usuallyEmployMapper.selectByEmployAndPassenger(employId, passengerId, serviceType);
    }

    @Override
    public int deleteById(Long id) {
        return usuallyEmployMapper.deleteByEmploy(id);
    }

    @Override
    public List<UsuallyEmploy> findUsuallyEmploy(Long passengerId, Integer offset, Integer size) {
        return usuallyEmployMapper.findByPassenger(passengerId, offset, size);
    }

    @Override
    public Long countUsuallyEmploy(Long passengerId) {
        return usuallyEmployMapper.countByPassenger(passengerId);
    }


}